package BubbleSort;
//冒泡排序

import java.util.Random;

public class Sort01 {
    public static void main(String[] args) {
        Random random = new Random();
        int[] b = new int[10];
        for (int i = 0; i < b.length; i++) {
            b[i] = random.nextInt(100);
        }
        for (int  i :b) {
            System.out.print(i+"   ");
        }
        System.out.println();
        sort(b);
        for (int ints :b) {
            System.out.print(ints+"   ");
        }

    }

    public static void sort(int[] a) {
        int tag = 1;
        for (int i = 0; tag == 1 && i < a.length-1; i++) {
            tag = 0;
            for (int j = 0; j < a.length -i  - 1; j++) {
                if (a[j + 1] < a[j]) {
                    int t = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = t;
                    tag = 1;
                }
            }
        }
    }
}
